package com.data.mapper;

import com.baomidou.mybatisplus.mapper.BaseMapper;
import com.data.entity.RoleUser;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

/**
 * @描述 <>
 * @参数 $params$
 * @返回值 $return$
 * @创建人 WangGuanghua
 * @创建时间 $date$
 */
@Mapper
public interface RoleUserMapper extends BaseMapper<RoleUser> {

    /**
     * 功能描述: <br>
     * 〈角色表先删除userid的外键〉
     * @Param: [userId]
     * @Return: void
     * @Author: wgh
     * @Date: 2019/8/21 0021 15:17
     */
    @Delete("DELETE from t_role_user  WHERE admin_id=#{adminId}")
    int deleteAdminById(@Param("adminId") long adminId);

    @Insert("<script>" +
            "insert into t_role_user (admin_id,role_id) " +
            "VALUES " +
            "(#{roleUser.userId},#{roleUser.roleId})" +
            "</script>")
    int add(@Param("roleUser") RoleUser roleUser);
}
